﻿using Entity.BaseInfo.DTO;
using Entity.BaseInfo.DTO.LogisticsCompany;
using Entity.BaseInfo.View.LogisticsCompany;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Service.BaseInfo;

namespace AnQinManagermentBackendAPI.Controller.BaseInfo
{
    /// <summary>
    /// 物流公司表
    /// </summary>
    [Route("api/[controller]")]
    [ApiController]
    [Authorize]
    public class LogisticsCompanyController : ControllerBase
    {
        /**
         * 物流公司业务接口
         */
        private readonly LogisticsCompanyService _logisticsCompanyService;

        /**
         * 构造函数注入
         */
        public LogisticsCompanyController(LogisticsCompanyService logisticsCompanyService)
        {
            _logisticsCompanyService = logisticsCompanyService;
        }

        /// <summary>
        /// 获取物流公司列表
        /// </summary>
        /// <param name="logisticsCompanySearchDTO"></param>
        [HttpGet]
        [ProducesResponseType(typeof(LogisticsCompanyView), 200)]
        public async Task<IActionResult> GetLogisticsCompanyList([FromQuery] LogisticsCompanySearchDTO logisticsCompanySearchDTO)
        {
            var response = await _logisticsCompanyService.GetLogisticsCompanyList(logisticsCompanySearchDTO);
            return StatusCode(response.Status, response);
        }

        /// <summary>
        /// 新增物流公司
        /// </summary>
        /// <param name="logisticsCompanyAddDTO"></param>
        [HttpPost]
        public async Task<IActionResult> AddLogisticsCompany([FromBody] LogisticsCompanyAddDTO logisticsCompanyAddDTO)
        {
            var response = await _logisticsCompanyService.AddLogisticsCompany(logisticsCompanyAddDTO);
            return StatusCode(response.Status, response);
        }

        /// <summary>
        /// 更新物流公司
        /// </summary>
        /// <param name="logisticsCompanyUpdateDTO"></param>
        [HttpPut]
        public async Task<IActionResult> PutLogisticsCompany([FromBody] LogisticsCompanyUpdateDTO logisticsCompanyUpdateDTO)
        {
            var response = await _logisticsCompanyService.PutLogisticsCompany(logisticsCompanyUpdateDTO);
            return StatusCode(response.Status, response);
        }

        /// <summary>
        /// 删除物流公司
        /// </summary>
        [HttpDelete]
        public async Task<IActionResult> DeleteLogisticsCompany([FromQuery] string Id)
        {
            var response = await _logisticsCompanyService.DeleteLogisticsCompany(Id);
            return StatusCode(response.Status, response);
        }

        /// <summary>
        /// 删除物流公司 - 批量
        /// </summary>
        [HttpPost("Multi")]
        public async Task<IActionResult> DeleteLogisticsCompanyMulti([FromBody] List<string> Ids)
        {
            var response = await _logisticsCompanyService.DeleteLogisticsCompanyMulti(Ids);
            return StatusCode(response.Status, response);
        }

        /// <summary>
        /// 启用物流公司 - 批量
        /// </summary>
        [HttpPost("Enable")]
        public async Task<IActionResult> EnableLogisticsCompany([FromBody] List<string> Ids)
        {
            var response = await _logisticsCompanyService.EnableLogisticsCompany(Ids);
            return StatusCode(response.Status, response);
        }

        /// <summary>
        /// 禁用物流公司 - 批量
        /// </summary>
        [HttpPost("Disable")]
        public async Task<IActionResult> DisableLogisticsCompany([FromBody] List<string> Ids)
        {
            var response = await _logisticsCompanyService.DisableLogisticsCompany(Ids);
            return StatusCode(response.Status, response);
        }
    }
}
